import config from './gameconfig.js';
class Block {
    constructor(x = 0, y = 0, imgSrc = config.DefaltSprite, width = config.BlockSize, height = config.BlockSize) {
        this.img = new Image();
        this.img.src = imgSrc;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    collision(other) {
        if (Math.abs(this.x + this.width / 2 - (other.x + other.width / 2)) <
            Math.abs(this.width + other.width) / 2 - config.CollistionReduce &&
            Math.abs(this.y + this.height / 2 - (other.y + other.height / 2)) <
                Math.abs(this.height + other.height) / 2 - config.CollistionReduce) {
            return true;
        }
        return false;
    }
    render(context) {
        if (!context)
            return;
        context.drawImage(this.img, this.x, this.y, this.width, this.height);
    }
}
export default Block;
